package org.example.rpc.framework;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @Desc:创建rpc服务器
 */
public class RpcServer {
    /**
     * 创建线程池
     */
    private ExecutorService executors = Executors.newFixedThreadPool(5);

    public void provide(int port){
        try {
            ServerSocket serverSocket = new ServerSocket(port);
            while (true){
                Socket socket = serverSocket.accept();
                executors.execute(new ProcessHandler(socket));
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

